<?php

require "./vendor/phpoffice/phpexcel/PHPExcel/PHPExcel.php";


class LoadExcel
{
    public function read($fileName)
    {
        try {
            $objReader = PHPExcel_IOFactory::createReader('Excel5');

            if (!$objReader->canRead($fileName)) {
                $objReader = PHPExcel_IOFactory::createReader('Excel2007');
                if (!$objReader->canRead($fileName)) {
                    return false;
                }
            }

            // $objReader->setReadDataOnly(true);

            $objPHPExcel = $objReader->load($fileName);
            $objWorksheet = $objPHPExcel->getActiveSheet();
            $highestRow = $objWorksheet->getHighestRow();
            $highestColumn = $objWorksheet->getHighestColumn();
            $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
            $excelData = array();

            for ($row = 1; $row <= $highestRow; $row++) {
                for ($col = 0; $col < $highestColumnIndex; $col++) {
                    $excelData[$row][] = (string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
                }
            }
        } catch (Exception $e) {
            $msg = $e->getLine() . ' ' . $e->getMessage() . ' ' . $e->getFile();
            return $msg;
        }
        return  $excelData;
    }
}

$test = new LoadExcel();
$res = $test->read("test.xlsx");
var_dump($res);
